define(["jquery", "easy-admin", "vue"], function ($, ea, Vue) {

    var form = layui.form
        ,laydate = layui.laydate;

    var Controller = {
        index: function () {
            let remind_time = laydate.render({
                elem:"#remind_time",
                type:'time'
            })
            //触发签到提醒
            form.on('switch(is_remind)', function(data){
                if(data.elem.checked === true){
                    $(".remind_time").removeClass('layui-hide');
                }else{
                    $(".remind_time").addClass('layui-hide');
                }
            });
            form.on('radio(is_continuity)', function(data){
                let value = data.value;
                if (value == 1) {
                    $(".continuity_rule").slideDown();
                }else{
                    $(".continuity_rule").slideUp();
                }
            });
            $(".add-rule").on('click',function () {
                let html = '<fieldset class="layui-elem-field">\n' +
                    '            <legend>规则:</legend>\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <label class="layui-form-label">连续签到天数</label>\n' +
                    '                <div class="layui-input-block">\n' +
                    '                    <input type="number" name="continuity_day[]" required  lay-verify="required" placeholder="请输入连续签到天数" autocomplete="off" class="layui-input">\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <label class="layui-form-label">赠送类型</label>\n' +
                    '                <div class="layui-input-block">\n' +
                    '                    <input type="radio" name="continuity_type[]" value="0" title="积分">\n' +
                    '                    <input type="radio" name="continuity_type[]" value="1" title="余额">\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <label class="layui-form-label">赠送数量</label>\n' +
                    '                <div class="layui-input-block">\n' +
                    '                    <input type="number" name="continuity_number[]" required  lay-verify="required" placeholder="请输入赠送数量" autocomplete="off" class="layui-input">\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '        </fieldset>';
                $(".rule_append").before(html);
                form.render();
            })
            //累计签到规则
            form.on('radio(is_cumulative)', function(data){
                let value = data.value;
                if (value == 1) {
                    $(".cumulative_rule").slideDown();
                }else{
                    $(".cumulative_rule").slideUp();
                }
            });
            $(".add-cumulative").on('click',function () {
                let html = '<fieldset class="layui-elem-field">\n' +
                    '            <legend>规则:</legend>\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <label class="layui-form-label">连续签到天数</label>\n' +
                    '                <div class="layui-input-block">\n' +
                    '                    <input type="number" name="cumulative_day[]" required  lay-verify="required" placeholder="请输入连续签到天数" autocomplete="off" class="layui-input">\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <label class="layui-form-label">赠送类型</label>\n' +
                    '                <div class="layui-input-block">\n' +
                    '                    <input type="radio" name="cumulative_type[]" value="0" title="积分">\n' +
                    '                    <input type="radio" name="cumulative_type[]" value="1" title="余额">\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '            <div class="layui-form-item">\n' +
                    '                <label class="layui-form-label">赠送数量</label>\n' +
                    '                <div class="layui-input-block">\n' +
                    '                    <input type="number" name="cumulative_number[]" required  lay-verify="required" placeholder="请输入赠送数量" autocomplete="off" class="layui-input">\n' +
                    '                </div>\n' +
                    '            </div>\n' +
                    '        </fieldset>';
                $(".cumulative_append").before(html);
                form.render();
            })

            ea.listen();
        }
    };
    return Controller;
});